<template>
<div>
  {{news}}
  <br>
  <br>
  <br>
  <p>
    <input type="text" v-model="frm.tlack">
    <button @click="add_tlack">评论</button>
  </p>
  <table align="center">
    <tr v-for="i in asd">
      <td>{{i.tlack}}</td>
    </tr>
  </table>
</div>
</template>

<script>
export default {
  name: "xiangqing",
  data(){
    return{
       news:this.$route.query.new,
       tid:this.$route.query.tid,
       frm:{'uid':this.userid,'tid':this.tid},
       userid:localStorage.getItem('userid'),
       asd:[]
    }
  },
  methods:{
    add_tlack(){
      if(!this.userid){
        alert('去登录')
        this.$router.push('/login')
      }else {
        this.$axios.post('users/tlacks',{'frm':this.frm,'tid':this.tid,'uid':this.userid}).then(res=>{
          if(res.data.code==200){
            alert('ok')
            this.frm={}
            this.get_pl()
          }else {'no'}
        })
      }
    },
    get_pl(){
      this.$axios.get('users/tlacks?tid='+this.tid).then(res=>{
        this.asd = res.data.list
      })
    }
  },
  mounted() {
    this.get_pl()
  }
}
</script>

<style scoped>

</style>
